package edu.pitt.dbmi.odie.gapp.gwt.model;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import edu.pitt.dbmi.odie.gapp.gwt.client.dao.ODIE_DaoCls;
import edu.upmc.opi.caBIG.common.CaBIG_UUIdGenerator;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ODIE_Cls {
	
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;
	
	@Persistent
	private String odieId;
	
	@Persistent
	private String odieAnalysisId;

	@Persistent
	private String  ontologyName ;

	@Persistent
	private String  clsName ;
	
	@Persistent
	private String  colorAsString ;
	
	@Persistent
	private String foundryKey ;
	
	@Persistent
	private String cui;
	
	@Persistent
	private String tuis;
	
	@Persistent
	private String stys;
	
	@Persistent
	private String synonyms;
	
	public ODIE_Cls() {
		this.odieId = CaBIG_UUIdGenerator.getUUID() ;
	}
    
    public String getOdieId() {
        return this.odieId ;
    }

    public String getOdieAnalysisId() {
		return odieAnalysisId;
	}

	public void setOdieAnalysisId(String odieAnalysisId) {
		this.odieAnalysisId = odieAnalysisId;
	}
	
	public String getOntologyName() {
		return ontologyName;
	}

	public void setOntologyName(String ontologyName) {
		this.ontologyName = ontologyName;
	}

	public String getClsName() {
		return clsName;
	}

	public void setClsName(String clsName) {
		this.clsName = clsName;
	}

	public String getColorAsString() {
		return colorAsString;
	}

	public void setColorAsString(String colorAsString) {
		this.colorAsString = colorAsString;
	}

	public String getFoundryKey() {
		return foundryKey;
	}

	public void setFoundryKey(String foundryKey) {
		this.foundryKey = foundryKey;
	}

	public String getCui() {
		return cui;
	}

	public void setCui(String cui) {
		this.cui = cui;
	}

	public String getTuis() {
		return tuis;
	}

	public void setTuis(String tuis) {
		this.tuis = tuis;
	}

	public String getStys() {
		return stys;
	}

	public void setStys(String stys) {
		this.stys = stys;
	}

	public String getSynonyms() {
		return synonyms;
	}

	public void setSynonyms(String synonyms) {
		this.synonyms = synonyms;
	}
	
	
	public ODIE_DaoCls convertToClientSideRecord() {
		ODIE_DaoCls result = new ODIE_DaoCls() ;
		result.setOdieId(this.odieId) ;
		result.setOdieAnalysisId(this.odieAnalysisId) ;
		result.setOntologyName(this.ontologyName) ;
		result.setClsName(this.clsName) ;
		result.setCui(this.cui) ;
		result.setColorAsString(this.colorAsString) ;
		return result ;
	}
	
	public String toXml() {
		StringBuffer sb = new StringBuffer() ;
		if (id != null) {
			sb.append("<cls>") ;
			sb.append("<id>"+getOdieId()+"</id>") ;
			sb.append("<odieAnalysisId>"+getOdieAnalysisId()+"</odieAnalysisId>") ;
			sb.append("<ontologyName>"+getOntologyName()+"</ontologyName>") ;
			sb.append("<clsName>"+getClsName()+"</clsName>") ;
			sb.append("<cui>"+getCui()+"</cui>") ;
			sb.append("<color>"+getColorAsString()+"</color>") ;
			sb.append("</cls>") ;
		}
		return sb.toString();
	}
}
